package ActiveMQ.p2p;

import java.util.concurrent.TimeUnit;

/**
 * Created by yangluhua on 2017/11/21 0021.
 */
public class MyActiveMQDemo {
    public static void main(String[] args) {
        //断线不重连
        //String url = "tcp://localhost:61616";
        //断线重连
        String url = "failover:(tcp://localhost:61616)?randomize=false";
        String user = "admin";
        String password = "admin";
        String query = "MyQueue";
        //启动消费者
        new Thread(new MessageReceiver(query,url,user,password), "Name-Receiver").start();
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //启动生产者
       new Thread(new MessageSender(query,url,user,password), "Name-Sender").start();
    }
}
